<%--
  Created by IntelliJ IDEA.
  User: kadsg
  Date: 2023/1/6
  Time: 2:45
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>预约记录</title>
</head>
<body>
<jsp:include page="../../head/manager.jsp"/>
<div class="accordion accordion-flush" id="accordionFlushExample">

  <div class="accordion-item">
    <h2 class="accordion-header unUsed">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
              data-bs-target="#unUsed" aria-expanded="false" aria-controls="unUsed">
        当前预约
      </button>
    </h2>
    <div id="unUsed" class="accordion-collapse collapse" aria-labelledby="unUsed"
         data-bs-parent="#accordionFlushExample">
      <div class="accordion-body">
        <c:if test="${unUsedRecords == null}">
          当前没有读者预约！
        </c:if>
        <c:if test="${unUsedRecords != null}">
          <table class="table table-hover">
            <tbody>
            <tr>
              <th>读者账号</th>
              <th>读者姓名</th>
              <th>联系方式</th>
              <th>楼层名</th>
              <th>座位号</th>
              <th>预约时间</th>
            </tr>
            <c:forEach items="${unUsedRecords}" var="record">
              <tr>
                <td>${record.id}</td>
                <td>${record.name}</td>
                <td>${record.phone}</td>
                <td>${record.floor_name}</td>
                <td>${record.number}</td>
                <td>${record.reserve_time}</td>
              </tr>
            </c:forEach>
            </tbody>
          </table>
        </c:if>
      </div>
    </div>
  </div>

  <div class="accordion-item">
    <h2 class="accordion-header in-use">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
              data-bs-target="#in-use" aria-expanded="false" aria-controls="in-use">
        正在使用
      </button>
    </h2>
    <div id="in-use" class="accordion-collapse collapse" aria-labelledby="in-use"
         data-bs-parent="#accordionFlushExample">
      <div class="accordion-body">
        <c:if test="${inUseRecords == null}">
          当前没有正在使用的座位！
        </c:if>
        <c:if test="${inUseRecords != null}">
          <table class="table table-hover">
            <tbody>
            <tr>
              <th>读者账号</th>
              <th>读者姓名</th>
              <th>联系方式</th>
              <th>楼层名</th>
              <th>座位号</th>
              <th>预约时间</th>
              <th>开始时间</th>
            </tr>
            <c:forEach items="${inUseRecords}" var="record">
              <tr>
                <td>${record.id}</td>
                <td>${record.name}</td>
                <td>${record.phone}</td>
                <td>${record.floor_name}</td>
                <td>${record.number}</td>
                <td>${record.reserve_time}</td>
                <td>${record.start_time}</td>
              </tr>
            </c:forEach>
            </tbody>
          </table>
        </c:if>
      </div>
    </div>
  </div>

  <div class="accordion-item">
    <h2 class="accordion-header completed">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
              data-bs-target="#completed" aria-expanded="false" aria-controls="completed">
        过往记录
      </button>
    </h2>
    <div id="completed" class="accordion-collapse collapse" aria-labelledby="completed"
         data-bs-parent="#accordionFlushExample">
      <div class="accordion-body">
        <c:if test="${completedRecords == null}">
          暂无记录！
        </c:if>
        <c:if test="${completedRecords != null}">
          <table class="table table-hover">
            <tbody>
            <tr>
              <th>读者账号</th>
              <th>读者姓名</th>
              <th>联系方式</th>
              <th>楼层名</th>
              <th>座位号</th>
              <th>预约时间</th>
              <th>开始时间</th>
              <th>结束时间</th>
              <th>状态</th>
            </tr>
            <c:forEach items="${completedRecords}" var="record">
              <tr>
                <td>${record.id}</td>
                <td>${record.name}</td>
                <td>${record.phone}</td>
                <td>${record.floor_name}</td>
                <td>${record.number}</td>
                <td>${record.reserve_time}</td>
                <c:if test="${record.cancel_flag == false}">
                  <td>${record.start_time}</td>
                  <td>${record.end_time}</td>
                  <td>已结束</td>
                </c:if>
                <c:if test="${record.cancel_flag == true}">
                  <td>-</td>
                  <td>-</td>
                  <td>读者取消</td>
                </c:if>
              </tr>
            </c:forEach>
            </tbody>
          </table>
        </c:if>
      </div>
    </div>
  </div>

</div>
</body>
</html>
